package com.accenture.fd.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.accenture.fd.entity.LogicalDataItemEntity;

@Mapper
public interface LogicalDataItemDao {

//	@Delete("delete from CM00001 where 1=1")
	@Delete("truncate table CM00001")
    void truncateLogicalDataItem();
    
    @Insert({
   	 "<script>",
   	 "insert into CM00001 value ",
   	 "<foreach collection='entityList' item='entity' index='index' separator=','>",
   	 "(#{entity.consecutive_no},#{entity.entity_physical_name},#{entity.entity_logical_name},#{entity.data_item_name},",
   	 "#{entity.column_cd},#{entity.pk},#{entity.fy},#{entity.related_entity_name},",
   	 "#{entity.data_type_cd},#{entity.size},#{entity.explanation_items},",
   	 "#{entity.login_date},#{entity.login_by},#{entity.update_date},",
   	 "#{entity.update_by},#{entity.effective_flag})",
   	 "</foreach>",
   	 "</script>"
   	})
    void saveLogicalDataItem(@Param(value="entityList") List<LogicalDataItemEntity> entityList);
    
    @Select("select \r\n" + 
     		"  data_item_name\r\n" + 
     		"from CM00001")
     @Results({
    	 @Result(property = "DataItemName", column = "data_item_name"),
     })
     List<String> getLogicalDataItemName();
}
